import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import Login from "../views/user/Login.vue"
import Team from "../views/team/Index.vue"
import Message from "../views/message/Index.vue"
import Register from "../views/user/Register.vue"
import ItemAdd from "../views/items/add/Index.vue"
import ItemShow from '../views/items/show/Index.vue'
import Basic from '../views/items/add/Basic.vue'
import Copy from '../views/items/add/Copy.vue'
import Import from '../views/items/add/Import.vue'
import OpenApi from '../views/items/add/OpenApi.vue'
import Attachment from '../views/attachment/Index.vue'
import Setting from '../views/user/setting/Index.vue'
import PageEdit from '../views/page/edit/Index.vue'

import { component } from 'vue/types/umd'
Vue.use(VueRouter)


// 路由的跳转逻辑
const routes: Array<RouteConfig> = [

  {
    path:"/",
    name:"Login",
    component:Login,
  },

  {
    path: '/item/Index',
    name: 'itemIndex',
    component: () => import('../views/items/Index.vue')
  },
  {
    path: '/team/index',
    name: 'Team',
    // component: () => import('../views/items/team/Index.vue')
    component: Team
  },
  {
    path: '/message/Index',
    name: 'Message',
    // component: () => import('../views/message/Index.vue')
    component: Message
  },
  {
    path: '/user/register',
    name: 'register',
    // component: () => import('../views/user/Register.vue')
    component: Register
  },
  {
    path: '/add/index',
    name: 'ItemAdd',
    component: ItemAdd
  },
  {
    path: '/add/Basic',
    name: 'Basic',
    component: Basic
  },
  {
    path: '/add/Copy',
    name: 'Copy',
    component: Copy
  },
  {
    path: '/add/Import',
    name: 'Import',
    component: Import
  },
  {
    path: '/add/OpenApi',
    name: 'OpenApi',
    component: OpenApi
  },

  {
    path: '/attachment/Index',
    name: 'Attachment',
    component: Attachment
  },
  
  {
    path: '/setting/Index',
    name: 'Setting',
    component: Setting
  },

  {
    path: '/page/edit/:itemId/:pageId',
    name: 'PageEdit',
    component: PageEdit
  },
  
  // -------新路由加在分割线前面---------------
  {
    path: '/:itemId',
    name: 'ItemShow',
    component: ItemShow
  },
  {
    path: '/:itemId/:page_id(\\d+)',
    name: 'ItemShow',
    component: ItemShow
  }
]

const router = new VueRouter({
  routes
})

//添加以下代码
// const originalPush = VueRouter.prototype.push
// VueRouter.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch((err: any) => err)
// }

export default router
